<template>
	<view class=" ">
		<view class="rowsb align-center " :style="{'padding-top':CustomBar+'rpx'}" style="opacity: 0;">
			<image src="/static/dynamic/imgfabu.png" mode="widthFix" style="width:80rpx;"></image>
		</view>
		<view class="rowsb align-center head  animation-slide-left" :style="{'padding-top':CustomBar+'rpx'}">
			<view style=" width: 660rpx;">
				<scroll-view scroll-x class="bg-white nav" scroll-with-animation :scroll-left="scrollLeft">
					<view class="cu-item" :class="index==TabCur?'tacurText animation-scale-up cur':''" v-for="(item,index) in categoryList"
						:key="item.id" @tap="tabSelect" :data-id="index">
						{{item.name}}
					</view>
				</scroll-view>
			</view>
			<view>
				<image src="/static/dynamic/imgfabu.png" mode="widthFix" style="width:80rpx;" @click="$tools.push('/pages/plugins/issue/issueDynamic')"></image>
			</view>
		</view>
		<view class="rowsc margin-top">
			<view class="stream ">
				<view class="video_list " v-for="(item,index) in dynamicList" :key="item.id" 
				@click="$tools.push(`detail?id=${item.id}`)">
					<image :src="item.cover" mode="widthFix" class="video_list "></image>
					<view class="video_bottom align-center padding-sm text-white  rowsb ">
						<view class="video_bottom_title one_overflow">{{item.title}}
						</view>
						<view>
							<image src="/static/dynamic/imgxiangji-5.png" mode="" class="video_icon" @click.stop=""></image>
							<image src="/static/dynamic/imgxiaoxi-2.png" mode="" class="video_icon margin-left"@click.stop=""></image>
						</view>
					</view>
					<view class="video_top text-white">
						<view style="height: 20rpx;width: 20rpx;background-color: #21BF53;" class="round"></view>
						<view class="margin-left-xs">在线</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		chatCategory
	} from '@/common/path.js'
	import {
		mapState,
		mapActions
	} from 'vuex'
	export default {
		data() {
			return {
				scrollLeft: 0,
				TabCur: 0,
				videoList: [{
						image: 'https://img0.baidu.com/it/u=517413663,1420490137&fm=26&fmt=auto'
					},
					{
						image: 'https://img0.baidu.com/it/u=1844422757,3295058760&fm=26&fmt=auto'
					},
					{
						image: '/static/ces.jpg'
					},
					{
						image: 'https://img2.baidu.com/it/u=4150900855,2140705546&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
					},
					{
						image: 'https://img1.baidu.com/it/u=335735232,2913383325&fm=26&fmt=auto'
					},
					{
						image: 'https://img1.baidu.com/it/u=4115505678,3537470771&fm=26&fmt=auto'
					}
				],
				categoryList: [], //分类列表
				catPid: '', //分类id
				pageData: 1 //第一页
			}
		},
		//生命周期函数
		onReady() {},
		onLoad() {
			this.chatCategory()
		},
		watch:{
			//根据id筛选
			TabCur(i) {
				console.log(i);
				this.pageData = 1
				this.catPid = this.categoryList[i].id
				this.getmomentsMen() //动态
			},
		},
		onShow() {

		},
		methods: {
			/**
			 *getmomentsApi 动态列表 
			 */
			...mapActions('dynamic', ['getmomentsApi']),
			//分类
			chatCategory() {
				this.Http.POST(chatCategory, {})
					.then((res) => {
						if (res.code == 0) {
							// console.log('[分类]', res);
							this.categoryList = res.data
							this.catPid = res.data[0].id
							this.getmomentsMen() //动态列表
						}
					})
			},
			getmomentsMen() {
				this.getmomentsApi({
					categoryId: this.catPid,
					pageSize: 10,
					pageNum: this.pageData
				})
			},
			onReachBottom(e) {
				this.pageData++
				this.getmomentsMen()
			},
			tabSelect(e) {
				this.TabCur = e.currentTarget.dataset.id
				console.log(this.TabCur);
				this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60
			},

		},
		computed: {
			...mapState('dynamic', ['dynamicList'])
		},
		components: {}
	}
</script>

<style>
	.head {
		position: fixed;
		left: 0;
		right: 0;
		z-index: 99;
		top: 0;
		background-color: white;
	}

	.swiper_image {
		width: 750rpx;
		height: 350rpx;
		background: #F7F6FA;
		opacity: 1;
	}

	.destined_body {
		width: 750rpx;
		height: 80rpx;
		background: #EAA019;
		opacity: 1;
	}

	.video_list {
		width: 342rpx;
		background: #EEEEEE;
		border-radius: 10rpx;
		position: relative;

	}

	.video_bottom {
		width: 100%;
		background: rgba(0, 0, 0, 0.4);
		opacity: 1;
		border-radius: 0px 7rpx 7rpx 0px;

		position: absolute;
		left: 0;
		z-index: 1;
		bottom: 0rpx;
	}

	.video_bottom_title {
		width: 180rpx;
	}

	.video_icon {
		height: 30rpx;
		width: 30rpx;
	}

	.video_top {
		position: absolute;
		top: 10rpx;
		align-items: center;
		display: flex;
		left: 20rpx;
	}

	.tacurText {
		color: #EAA019;
	}

	.stream {
		-webkit-column-count: 2;

		/* -moz-column-count: 2; */
		/* column-count: 2; */
		/* -moz-column-gap: 30rpx; */
		/* -webkit-column-gap: 30rpx; */
		/* display: inline-block; */
	}
	.tabbar2 {
		width: 750rpx;
		height: 100rpx;
		position: fixed;
		z-index: 9998;
		bottom: 0;
		left: 0;
		right: 0;
	}
</style>
